#include "StdAfx.h"
#include "dmanagevariabledlg.h"

DManageVariableDlg::DManageVariableDlg(QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);

	QButtonGroup* pButtonGroup = new QButtonGroup(this);
	pButtonGroup->addButton(ui.radioPublic);
	pButtonGroup->addButton(ui.radioProtected);
	pButtonGroup->addButton(ui.radioPrivate);

	ui.radioPublic->setChecked(true);

	QObject::connect(ui.editType, SIGNAL(textChanged(const QString&)), this, 
					SLOT(onVarTypeChanged(const QString&)));

	QObject::connect(ui.editName, SIGNAL(textChanged(const QString&)), this, 
					SLOT(onVarNameChanged(const QString&)));

	ui.buttonOK->setEnabled(false);
}

DManageVariableDlg::~DManageVariableDlg()
{

}

void DManageVariableDlg::onVarTypeChanged(const QString& type)
{
	if(type.isEmpty())
	{
		ui.buttonOK->setEnabled(false);
	}
	else
	{
		ui.buttonOK->setEnabled(true);
	}
}

void DManageVariableDlg::onVarNameChanged(const QString& name)
{
	if(name.isEmpty())
	{
		ui.buttonOK->setEnabled(false);
	}
	else
	{
		ui.buttonOK->setEnabled(true);
	}
}